#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "Image.h"
#include "QImage"
#include<iostream>
using namespace std;



MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    QString filename;
    filename=QFileDialog::getOpenFileName(this,
                                        tr("选择图像"),
                                        "",
                                        tr("Images (*.png *.bmp *.jpg *.tif *.GIF )"));//可打开的文件类型
    if(!filename.isEmpty())
    {

        if(! ( img->load(filename) ) ) //加载图像
            {
                QMessageBox::information(this,
                                         tr("打开图像失败"),
                                         tr("打开图像失败!"));
                delete img;
            }

        ui->label->setPixmap(QPixmap::fromImage(*img));

        myimg.SetHeight(img->height());
        myimg.SetWidth(img->width() * 3);
        myimg.First_to_Secon(img->bits());

    }
}

void MainWindow::on_pushButton_2_clicked()
{
    myimg.Secon_to_First(img->bits());
  img->save("F:/Qt//Image/build-Image-Desktop_Qt_5_14_1_MinGW_64_bit-Debug/Fruits.bmp");
}

void MainWindow::on_pushButton_3_clicked()
{
    myimg.sharpen();
    myimg.Secon_to_First(img->bits());
    ui->label->setPixmap(QPixmap::fromImage(*img));

}

void MainWindow::on_pushButton_4_clicked()
{
    myimg.Grey_scale();
    myimg.Secon_to_First(img->bits());
    ui->label->setPixmap(QPixmap::fromImage(*img));

}
